home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 10
/
FM Towns Free Software Collection 10.iso
/
ms_dos
/
tool
/
dprint
/
dp_main.c
< prev
next >
Wrap
Text File
|
1995-01-01
|
3KB
|
165 lines
/*
8086|Printman/POSTCARD エディタモジュール
Copyright (c) 1993,94 Delmonta
*/
#include<farstr.h>
#include"dprint.h"
struct POSTCARD far *Card[MAXCARD];
unsigned Cardnum;
unsigned Cardpos;
int Ypos;
/*---------------------------------------------------------------------------*/
static bool newcard(void)
{
if (Cardpos==Cardnum)
{
if (!addcard(Cardpos))
return FALSE;
else
{
Cardnum++;
dp_putcardnum();
printf("\033[%d;33f",Ypos+7);
}
}
return TRUE;
}
/*---------------------------------------------------------------------------*/
static void menu_patch(void)
{
char buf[25];
if (Cardpos < Cardnum)
far_strcpy(buf,Card[Cardpos]->data[Ypos]);
else
buf[0] = '\0';
if (strinput(buf,24))
{
if (newcard())
{
far_strcpy(Card[Cardpos]->data[Ypos],buf);
Changedflag = TRUE;
}
}
}
/*---------------------------------------------------------------------------*/
static void menu_inputzipcode(void)
{
int buf[5];
int i = 0;
char c;
printf(" - \b\b\b\b\b\b");
while(1)
{
c = dp_getch();
if (c=='\b' && i>0) /* BSキー */
{
i--;
if (i == 2)
printf("\b\b \b\b");
else
printf("\b \b");
}
else if ('0'<=c && c<='9' && i<5) /* 数字キー */
{
putchar(c);
buf[i++] = (int)c-'0';
if (i==3)
putchar('-');
}
else if (c=='\r' && (i==0 || i==3 || i==5))
{
if (!newcard())
return;
if (i==0)
Card[Cardpos]->zipcode[0] = -1;
else
{
Card[Cardpos]->zipcode[0]
= buf[0]*100 + buf[1]*10 + buf[2];
if (i==3)
Card[Cardpos]->zipcode[1] = -1;
else
Card[Cardpos]->zipcode[1]
= buf[3]*10 + buf[4];
}
Changedflag = TRUE;
return;
}
else if (c=='\033')
return;
else
putchar('\a');
}
}
/*---------------------------------------------------------------------------*/
void dp_main(void)
{
char c;
Ypos = -1;
dpmain_keyrep:
printf("\033[%d;33f\033[7;37m",Ypos+7);
card_reshow(1<<(Ypos+1));
printf("\033[0;37m\033[%d;33f",Ypos+7);
switch ( c=dp_getch())
{
case UPKEY:
if (Ypos > -1)
{
card_reshow(1<<(Ypos+1));
Ypos--;
}
break;
case DOWNKEY:
if (Ypos < 4)
{
card_reshow(1<<(Ypos+1));
Ypos++;
}
break;
case EXTKEY_H:
dp_funcmenu();
break;
default:
if (c<' ')
putchar('\7');
else
{
dp_ungetch(c);
if (Ypos>=0)
menu_patch();
else
menu_inputzipcode();
}
break;
}
goto dpmain_keyrep;
}